import { BasicFetchResult } from '/@/api/model/baseModel';

export interface NamespaceItem {
  value: string;
  description: string;
}

export interface CesRuleItem {
  name: string;
  status: string;
  monitoredObject: string;
  policies: string;
  resourceType: string;
  topics: string;
  button: string;
}

export interface EventDetailList {
  eventType: string;
  eventName: string;
  eventSource: string;
  time: number;
  timeStr: string;
  resourceId: string;
  eventLevel: string;
  eventState: string;
  eventUser: string;
  content: string;
}

export interface EventList {
  eventType: string;
  eventName: string;
  latestEventSource: string;
  eventCount: number;
  latestOccurTime: number;
  total: number;
  latestOccurTimeStr: string;
}

export interface EventUserList {
  eventUser: string;
}

export interface EventSourceList {
  eventSource: string;
}

export interface CceRuleItem {
  alarmRuleName: string;
  stateValue: string;
  type: string;
  namespace: string;
  dimensions: string;
  threshold: string;
  comparisonOperator: string;
  metricName: string;
  statistic: string;
  typeName?: 'PAAS ' | 'SAAS';
}

export interface CesRecordItem {
  alarmId: string;
  alarmtPolicy: string;
  endTime: string;
  level: string;
  name: string;
  recordId: string;
  resourceInstance: string;
  resourceType: string;
  status: string;
  topics: string;
}

export interface dimensionItem {
  description: string;
  value: string;
}

export interface resourceItem {
  metricId: string;
  metricName: string;
  unit: string;
}

export interface CceRecordItem {
  eventName: string;
  eventSeverity: string;
  resourceProvider: string;
  resourceType: string;
  resourceId: string;
  message: string;
  startsAt: string;
  alertType: string;
}

export type CesRuleResult = BasicFetchResult<CesRuleItem[]>;
export type CesRecordResult = BasicFetchResult<CesRecordItem[]>;

export type CesRuleParams = {
  offset: string;
  namespace: string;
  name: string;
};

export type CesRecordParams = {
  offset: string;
  namespace: string;
  level: string;
  name: string;
  status: string;
  alarmId: string;
  resourceId: string;
  from: string;
  to: string;
};

export type MetadataRelation = {
  key: string;
  relation: string;
  value: string[];
};

export type SortRequest = {
  order: string;
  orderBy: string[];
};

export type CceRecordParams = {
  timeRange: string;
  limit?: string[];
  eventType: Array<string>;
  eventSeverity: Array<string>;
  resourceType: Array<string>;
  metadataRelation: MetadataRelation[];
  sort: SortRequest;
};

export type dimensionParams = {
  namespace: string;
};
export type ResourceListParams = {
  namespace: string;
  dimension: string;
};

export type EventListParams = {
  alarmType: string;
  namespace: string;
};

export type MetricsListParams = {
  namespace: string;
  dimension: string;
};

export type ActionParams = {
  alarmId: string;
  status: string;
};

export type DeleteCesParams = {
  alarmId: string;
};

export type DeleteCceParams = {
  alarmRuleId: string;
};

export type CceDimensionParams = {
  namespace: string;
  metricName: string;
};

export interface CceDimensionsKV {
  key: string;
  value: string;
}

export type CceDimensionValueParams = {
  namespace: string;
  metricName: string;
  key: string;
};

export type CceMetricNameChildren = {
  title: string;
  key: string;
  value: string;
  metricName: string;
  metricNameZh: string;
};

export interface CceMetricNameItem {
  namespace: string;
  key: string;
  value: string;
  title: string;
  children: CceMetricNameChildren[];
}

export interface CceDimensionItem {
  dimensions: string[];
}

export type dimension = {
  key: string;
  value: string;
};

export interface CceAlertRuleItem {
  alarmRuleId: string;
  alarmRuleName: string;
  alarmDescription: string;
  namespace: string;
  ruleType: string;
  metricName: string;
  dimensions: string[];
  period: string;
  statistic: string;
  stateValue: string;
  comparisonOperator: string;
  threshold: string;
  evaluationPeriods: string;
  alarmLevel: string;
}

export type CceAlertRuleParams = {
  alarmRuleName: string;
  alarmDescription: string;
  namespace: string;
  ruleType: string;
  metricName: string;
  dimensions: string[];
  period: string;
  statistic: string;
  comparisonOperator: string;
  threshold: string;
  evaluationPeriods: string;
  alarmLevel: string;
};

export type DetailRuleParams = {
  alarmRuleId: string;
};

export type Policies = {
  metricName: string;
  filter: string;
  period: string;
  comparisonOperator: string;
  value: string;
  count: string;
  suppressDuration: string;
  level: string;
  unit: string;
};

export type CesCreateRuleParams = {
  name: string;
  description: string;
  resourceType: string;
  ruleType: string;
  dimension: string;
  eventType: string;
  monitoringScope: string;
  resource: string;
  policies: Policies[];
  notificationEnabled: boolean;
  smnUrns: string[];
  notificationBeginTime: string;
  notificationEndTime: string;
  notificationTime: string[];
  notificationTrigger: string[];
  alarmTrigger: boolean;
  okTrigger: boolean;
  enabled: boolean;
};

export type CesEditRuleParams = {
  alarmId: string;
  policies: Policies[];
};

export type SmnUrns = {
  displayName: string;
  topicUrn: string;
};

export interface CesDetail {
  name: string;
  description: string;
  resourceType: string;
  ruleType: string;
  dimension: string;
  dimensionValue: string;
  eventType: string;
  monitoringScope: string;
  resource: string;
  policies: Policies[];
  notificationEnabled: boolean;
  smnUrns: SmnUrns[];
  tempUrns: string[];
  notificationBeginTime: string;
  notificationEndTime: string;
  notificationTime: string[];
  notificationTrigger: string[];
  alarmTrigger: boolean;
  okTrigger: boolean;
  enabled: boolean;
}

export type CesDetailParams = {
  alarmId: string;
};

export type CesRecordDetailParams = CesDetailParams;

export type AlarmData = {
  description: string;
  value: string;
};

export interface CesRecordDetailItem {
  monitorName: string;
  ruleType: string;
  alarmData: AlarmData[];
}

export type EventQueryParams = {
  eventType?: string;
  eventName?: string;

  from?: string;
  to?: string;
  current?: number;
  size?: number;
};

export type EventUserQueryParams = {
  eventType: string;
  eventName: string;
  type: string;
  from?: number;
  to?: number;
};

export type EventSourceQueryParams = {
  eventType: string;
  eventName: string;
  type: string;
  from?: number;
  to?: number;
};

export type EventUserListResultModel = BasicFetchResult<EventUserList>;

export type EventSourceListResultModel = BasicFetchResult<EventSourceList>;

export type EventListResultModel = BasicFetchResult<EventList>;

export type EventDetailQueryParams = {
  eventLevel?: string;
  eventUser?: string;
  eventState?: string;
  eventSource?: string;
  current?: number;
  eventName: string;
  eventType: string;
  from?: number;
  to?: number;
  size?: number;
};

export type EventCustomParams = {
  eventType: string;
  current: string;
  size: string;
};

export type EventDetailListResultModel = BasicFetchResult<EventDetailList>;
